package com.taritari.journal.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.taritari.journal.entity.po.SdImg;
import com.taritari.journal.services.SdImgService;
import com.taritari.journal.utils.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.LinkedList;
import java.util.List;
import java.util.Map;

/**
 * @author taritari
 * @date 2024-04-21 14:06
 * @description
 */
@RestController
@Slf4j
@Tag(name = "sd生成的图片", description = "sd生成的图片")
@RequestMapping("/sdImg")
public class SdImgController {
    @Autowired
    private SdImgService sdImgService;

    @PostMapping("/generationImg")
    @Operation(summary = "通过prompt生成图片", description = "通过prompt生成图片")
    public Result generationImg(@RequestBody SdImg sdImg) {
        Map<String, String> stringStringMap = sdImgService.generateImgByPrompt(sdImg);

        return Result.success(stringStringMap);
    }

    /**
     * 添加
     * */
    @PostMapping("/add")
    @Operation(summary = "添加sdImg表", description = "添加sdImg表")
    public Result addImg(@RequestBody SdImg sdImg) {
        long  i = sdImgService.addSdImg(sdImg);
        return Result.success(i);
    }
    /**
     * 通过id分页查询
     * */
    @GetMapping("/query")
    @Operation(summary = "通过用户ID分页", description = "通过用户ID分页")
    public Result queryById(@RequestParam("authorId") int authorId,@RequestParam("currentPage") long currentPage) {
        Page<SdImg> sdImgByPage = sdImgService.getSdImgByPage(currentPage, authorId);
        return Result.success(sdImgByPage);
    }


}
